package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.CollectionAttention;
import com.sc.nft.entity.dto.DaoAttentionListVO;
import com.sc.nft.entity.dto.SecondCollectionConfigDTO;
import com.sc.nft.mapper.DaoAttentionMapper;
import com.sc.nft.entity.DaoAttention;
import com.sc.nft.service.DaoAttentionService;
import com.sc.nft.sup.PageRequest;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * dao关注(DaoAttention)表Dao层
 *
 * @author 王伟成
 * @since 2024-03-06 17:05:20
 */
@Slf4j
@Repository
public class DaoAttentionDao extends ServiceImpl<DaoAttentionMapper, DaoAttention> {
    /**
     * 获取用户是否有关注一个藏品
     * @param userId
     * @param daoId
     * @return
     */
    public DaoAttention getUserIdAndCollectionId(Long userId, Long daoId) {
        LambdaQueryWrapper<DaoAttention> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(DaoAttention::getUserId,userId);
        wrapper.eq(DaoAttention::getDaoId,daoId);
        return getOne(wrapper);
    }
    public IPage<DaoAttentionListVO> attentionList(Long userId, PageRequest pageRequest) {
        return baseMapper.attentionList(pageRequest.toMp(), userId);
    }
//    public IPage<SecondCollectionConfigDTO> attentionList(Long userId, PageRequest pageRequest) {
//        Page<Object> objectPage = new Page<>(pageRequest.getPageNo(), pageRequest.getPageSize());
//        objectPage.setSearchCount(false);
//        objectPage.setTotal(baseMapper.attentionListCount(userId));
//        return baseMapper.attentionList(objectPage, userId);
//    }
}
